package cn.edu.imau.zy.system.controller;

import cn.edu.imau.zy.common.core.entity.system.SysGradeYear;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.edu.imau.zy.common.annotation.LoginUser;
import cn.edu.imau.zy.common.core.entity.system.SysUser;

import cn.edu.imau.zy.common.core.domain.R;
import cn.edu.imau.zy.common.core.controller.BaseController;
import cn.edu.imau.zy.system.service.ISysGradeYearService;

import java.util.List;

/**
 * 年级 提供者
 * 
 * @author wyz
 * @date 2020-06-24
 */
@RestController
@RequestMapping("gradeYear")
public class SysGradeYearController extends BaseController
{
	
	@Autowired
	private ISysGradeYearService sysGradeYearService;
	
	/**
	 * 查询${tableComment}
	 */
	@GetMapping("get/{year}")
	public SysGradeYear get(@PathVariable("year") Long year)
	{
		return sysGradeYearService.selectSysGradeYearById(year);
		
	}
	
	/**
	 * 查询年级列表-分页
	 */
	@GetMapping("list")
	public R list(SysGradeYear sysGradeYear)
	{
		startPage();
        return result(sysGradeYearService.selectSysGradeYearList(sysGradeYear));
	}

	/**
	 * 查询年级列表
	 */
	@GetMapping("jlist")
	public List<SysGradeYear> jList(SysGradeYear sysGradeYear)
	{
		return sysGradeYearService.selectSysGradeYearList(sysGradeYear);
	}
	
	/**
	 * 新增保存年级
	 */
	@PostMapping("save")
	public R addSave(@RequestBody SysGradeYear sysGradeYear,@LoginUser SysUser user)
	{
		sysGradeYear.setCreateBy(user.getUserId().toString());
		return toAjax(sysGradeYearService.insertSysGradeYear(sysGradeYear));
	}
	
	/**
	 * 删除${tableComment}
	 */
	@PostMapping("remove")
	public R remove(String ids)
	{		
		return toAjax(sysGradeYearService.deleteSysGradeYearByIds(ids));
	}
	
}
